package server

import (
	"fmt"
	"github.com/robertkrimen/otto"
	"io/ioutil"
)

func ReadJs() {
	//先读入文件内容
	bytes, err := ioutil.ReadFile("D:/projects/test/test_go/server/calendar.js")
	if err != nil {
		panic(err)
	}

	vm := otto.New()

	_, err = vm.Run(string(bytes))
	if err != nil {
		panic(err)
	}

	value, _ := vm.Run("calendar.monthDays(1987, 6)")
	{
		// value is an int64 with a value of 16
		aaa, _ := value.ToInteger()
		fmt.Println("=====", aaa)
	}

}
